<template>
  <div>
    <a-button  :disabled="status==='申请修改个人信息待审核'|| status=='申请修改个人信息已通过'" :class="{'view':!(status==='申请修改个人信息待审核')}" type='primary' @click='showModal'>
      修改信息
    </a-button>
    <a-modal
      title='申请修改信息'
      :visible='visible'
      :confirm-loading='confirmLoading'
      @ok='handleok'
      @cancel='handlecancel'
      okText='提交申请'
    >
      <a-textarea v-model='ModalText' rows='4' placeholder='请输入申请理由' />
    </a-modal>
  </div>
</template>

<script>
import { postAction } from '@/api/manage'

export default {
  props:{
    status:{
      default:'',
      type: String
    },
  },
  name: 'QRcode',
  data() {
    return {
      ModalText: '',
      visible: false,
      confirmLoading: false,
      isdisabled:false,
      url: '/org/diyProfessorInfo/modeify'
    }
  },
  methods: {
    showModal() {
      this.visible = true
    },
    handleok(e) {
      //向后端发送axios请求
        let params = {
          ModalText: this.ModalText
        }
        let cont=this.ModalText
        //如果你的消息内容删掉空格之后不等于空 那么你的消息肯定有值
        if (cont.replace(/(^\s*)|(\s*$)/g) === '' || cont.toString()=== ''||cont.toString()===undefined ||cont==='') {
          this.$message.warning("修改信息申请理由不能为空!")
          this.visible=true;
        } else {
          if(!this.disabled){
            this.disabled=true
            postAction(this.url, params).then((res) => {
            if (res.success == true) {
              this.$message.success('您的信息已受理，请等待审核结果！')
              this.visible = false
              location.reload()
              setTimeout(()=>{
                //30s之内只能点击一次
                this.disabled=false;
              },30000)
            } else {
              this.$message.error('发送失败！')
              this.visible = false
            }
          })}
        }

    },
    handlecancel(e) {
      this.visible = false
    }
  }
}
</script>

<style scoped>
.view{
  color: #fff;
  background-color: #93adff;
  border-color: #93adff;
  text-shadow: 0 -1px 0 rgb(0 0 0 / 12%);
  box-shadow: 0 2px 0 rgb(0 0 0 / 5%);
}
</style>